<template>
  <div class="nav">
    <el-icon><HomeFilled /></el-icon>
    <span> / 医院信息</span>
  </div>
  <div class="hospital">
    <div class="left">
      <el-menu
        :default-active="$route.path"
        class="el-menu-vertical-demo"
        active-text-color="#1890ff"
        text-color="#7f7f7f"
      >
        <el-menu-item
          index="/hospital/register"
          @click="changeActive('/hospital/register')"
        >
          <el-icon><icon-menu /></el-icon>
          <span>预约挂号</span>
        </el-menu-item>
        <el-menu-item
          index="/hospital/detail"
          @click="changeActive('/hospital/detail')"
        >
          <el-icon><icon-menu /></el-icon>
          <span>医院详情</span>
        </el-menu-item>
        <el-menu-item
          index="/hospital/notice"
          @click="changeActive('/hospital/notice')"
        >
          <el-icon><icon-menu /></el-icon>
          <span>预约须知</span>
        </el-menu-item>
        <el-menu-item
          index="/hospital/close"
          @click="changeActive('/hospital/close')"
        >
          <el-icon><icon-menu /></el-icon>
          <span>停诊信息</span>
        </el-menu-item>
        <el-menu-item
          index="/hospital/search"
          @click="changeActive('/hospital/search')"
        >
          <el-icon><icon-menu /></el-icon>
          <span>查询/取消</span>
        </el-menu-item>
      </el-menu>
    </div>
    <div class="right">
      <!-- <el-skeleton :rows="5" /> -->
      <!-- <ElSkeleton :rows="5" /> -->
      <router-view></router-view>
    </div>
  </div>
</template>

<script setup lang="ts">
// import { ElSkeleton } from "element-plus";
import { onMounted } from "vue";
import useDetailStore from "@/store/modules/hospitalDetail.ts";
// 获取仓库对象
let detailStore = useDetailStore();
import { HomeFilled, Menu as IconMenu } from "@element-plus/icons-vue";
import { useRouter, useRoute } from "vue-router";
let $router = useRouter();
let $route = useRoute();
// 左侧菜单点击事件的回调
const changeActive = (path: string) => {
  $router.push({ path, query: { hoscode: $route.query.hoscode } });
};
// 组件挂载完毕：通知pinia仓库发请求获取医院详情的数据，存储仓库当中
onMounted(() => {
  // 获取某一医院详情的数据
  detailStore.getHospital(<string>$route.query.hoscode);
  // 获取某一医院科室的数据
  detailStore.getDeparment($route.query.hoscode as string);
});
</script>

<style scoped lang="scss">
.nav {
  margin: 20px 0 20px 25px;
  color: #7f7f7f;
  font-size: 14px;
  display: flex;
  span {
    margin-left: 5px;
  }
}
.hospital {
  display: flex;
  flex-direction: row;
  .left {
    flex: 1.5;
    .el-menu-item {
      height: 50px;
      // color: #7f7f7f;
      font-size: 14px;
      // border: 1px solid red;
      &:hover {
        .el-icon {
          color: #409eff;
          transition-duration: 0.4s;
        }
        background-color: #ffffff;
      }
    }
    .is-active {
      background-color: #e6f7ff !important;
      span {
        color: #7f7f7f;
      }
    }
  }
  .right {
    flex: 8.5;
    padding-left: 20px;
  }
}
</style>
